<!DOCTYPE html>
<html lang="en">
<head>
  <meta charset="UTF-8">
  <meta http-equiv="X-UA-Compatible" content="IE=edge">
  <meta name="viewport" content="width=device-width, initial-scale=1.0">
  <title>替换所有的问号</title>
</head>
<body>
  <script>
    var arr = '?????mxz'
    function fn(s) {
      var s = (`${s}`).split('')
      for(let i = 0; i < s.length; i++) {
        if(s[i] === '?') {
          s[i] = random(s[i - 1], s[i + 1])
        }
      }
      return s.join('').replace(/ /g, '')
    }
    function random(n, m) {
      let str = 'abcdefghijklmnopqrstuvwxyz'
      str = str.replace(n, '')
      str = str.replace(m, '')
      const randomNums = Math.round(Math.random() * 23)
      // console.log(str[randomNums],str)
      return str[randomNums]
    }
    console.log(fn(arr))
  </script>
</body>
</html>